<?php


namespace App\Listener;

use App\Event\ArticlePulished;
use App\Service\SearchService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\Event\Contract\ListenerInterface;

/**
 * 文章发布成功事件侦听器
 * 作者 薛原
 * 用于文章发布成功后续操作，如推送es
 * Class ArticlePulishListener
 * @package App\Listener
 */
class ArticlePulishListener implements ListenerInterface
{
    private \App\Service\UserProfilesService $userProfilesService;

    #[Inject]
    private SearchService $searchService;

    public function __construct() {

    }
    public function listen(): array {
        return [ArticlePulished::class];
    }
    public function process(object $event): void {
        $this->searchService->syncArticleToES($event->article_data);
    }
}